﻿using System;
using System.Configuration;
using System.Text;
using System.Data;
using System.Collections.Generic;

namespace RCMS.Web
{
    /// <summary>
    ///  Utility 
    /// </summary>
    public class Utility
    {
        #region 转换可用积分
        /// <summary>
        /// 转换可用积分
        /// </summary>
        public static int GetPointLevel()
        {
            int level = 0;
            if (!int.TryParse(ConfigurationSettings.AppSettings["PointLevel"], out level))
            { throw new Exception("转换可用积分配置不正确！"); }

            if (level == 0)
            { throw new Exception("转换积分基数不能为0！"); }
            return level;
        }

        public static int GetPoint(int input)
        {
            return input / GetPointLevel();
        }

        #endregion

        #region 金银卡维持积分
        /// <summary>
        /// 转换可用积分
        /// </summary>
        public static int GetGoldPointLevel()
        {
            int level = 0;
            if (!int.TryParse(ConfigurationSettings.AppSettings["GoldPointLevel"], out level))
            { throw new Exception("金卡维持积分配置不正确！"); }

            return level;
        }

        public static int GetSilverPointLevel()
        {
            int level = 0;
            if (!int.TryParse(ConfigurationSettings.AppSettings["SilverPointLevel"], out level))
            { throw new Exception("银卡维持积分配置不正确！"); }

            return level;
        }

        #endregion

        #region 金银卡维持积分
        /// <summary>
        /// 转换可用积分
        /// </summary>
        public static bool GetStoreInventoryFlag()
        {
            bool blnStoreInventoryFlag = false;
            Boolean.TryParse(ConfigurationSettings.AppSettings["StoreInventoryFlag"], out blnStoreInventoryFlag);

            return blnStoreInventoryFlag;
        }
        #endregion
    }
}